<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
debugger;
var x = '${user.departmentName}';
	$(function() {
		$('#departmentId').combobox({
			url : '${ctx}/department/listName',
			valueField: 'id',
			textField: 'text'
		});
		$('#departmentId').combobox('select','${user.departmentName}');
		
		$('#userEditForm').form({
			url : '${ctx}/user/edit',
			onSubmit : function() {
				progressLoad();
				var isValid = $(this).form('validate');
				if (!isValid) {
					progressClose();
				}
				return isValid;
			},
			success : function(result) {
				debugger;
				progressClose();
				result = $.parseJSON(result);
				if (result.status.errorCode == 0) {
					parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
					parent.$.modalDialog.handler.dialog('close');
				} else {
					parent.$.messager.alert('错误', result.result.errorMsg, 'error');
				}
			}
		});
	});
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false" title="" style="padding: 3px;">
		<form id="userEditForm" method="post">
			<table class="grid">
				<tr>
					<td>用户名</td>
					<td>
						<input name="id" type="hidden"  value="${user.id}">
						<input name="username" type="text" class="easyui-validatebox" data-options="required:true,validType:'account[1,16]'" value="${user.username}" disabled>
					</td>
					<td>姓名</td>
					<td><input name="name" type="text" class="easyui-validatebox" data-options="required:true,validType:'chinese[2,4]'" value="${user.name}" disabled></td>
				</tr>
				<tr>
					<td>年龄</td>
					<td><input name="age" type="number" class="easyui-validatebox" data-options="validType:['checkNum','length[1,3]']" value="${user.age}" disabled/></td>
					<td>性别</td>
					<td><select name="sex" class="easyui-combobox" data-options="width:140,height:29,editable:false,panelHeight:'auto'">
						<c:forEach items="${sexList}" var="sexList">
							<option value="${sexList.key}" <c:if test="${sexList.key == user.sex}">selected="selected"</c:if>>${sexList.value}</option>
						</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td>身份证号</td>
					<td><input name="idNumber" type="text" class="easyui-validatebox" data-options="required:true,validType:'idcard'" value="${user.idNumber}" disabled/></td>	
					<td>手机</td>
					<td><input name="cellphone"  type="text" class="easyui-validatebox" data-options="validType:['checkNum','length[11,11]']" value="${user.cellphone}" /></td>
				</tr>
				<tr>
					<c:if test="${sessionInfo.roleId == 1 }">
						<td>科室</td>
						<td><select id="departmentId" style="width: 140px; "></select></td>
					</c:if>
				</tr>
				<tr>
					<td>描述(1024以内)</td>
					<td colspan="3"><textarea name="description" rows="15" cols="80" maxlength="1024">${user.description}</textarea></td>
				</tr>
				
			</table>
		</form>
	</div>
</div>